from django.db import models

# Create your models here.


class UserModel(models.Model):
    username = models.CharField(max_length=20)
    password = models.CharField(max_length=120)
    level = models.CharField(max_length=5, choices=((0, '普通'), (1, 'VIP')), default=0)
    money = models.FloatField(default=0)


class PriceModel(models.Model):
    level = models.CharField(max_length=5, choices=((0, '普通'), (1, 'VIP')))
    price = models.FloatField()


class StoryModel(models.Model):
    title = models.CharField(max_length=20)
    what = models.CharField(max_length=200)
    level = models.CharField(max_length=5, choices=((0, '普通'), (1, 'VIP')))
    num = models.IntegerField(default=0)


class RecordModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE)
    story = models.ForeignKey(StoryModel, on_delete=models.CASCADE)
    start = models.DateTimeField(auto_now_add=True)
    end = models.DateTimeField(auto_now=True)
    time = models.FloatField(null=True)
    money = models.FloatField(null=True)


class NumBer(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE)
    story = models.ForeignKey(StoryModel, on_delete=models.CASCADE)
    num = models.IntegerField(default=0)